package org.rc.web;

import org.rc.model.Race;

import java.util.ArrayList;
import java.util.List;

/**
 * Model for a jquery datatable for displaying races
 * @author dokeeffe
 */
public class RaceTablePage extends JqueryDataTablePage<Race> {

    public RaceTablePage(List<Race> data) {
        loadTable(data);
    }
    
    public void loadTable(List<Race> data) {
        this.setAaData(new ArrayList<List<String>>()); 
        for(Race r : data) {
            List<String> row = new ArrayList<String>();
            row.add(r.getDate().toString());
            row.add(r.getName());
            row.add(""+r.getMiles());
            row.add(""+r.getId());
            getAaData().add(row);
        }
    }
    
}
